//
//  SCApiTool+base.m
//  ScalperMerchant
//
//  Created by 王云 on 2017/10/9.
//  Copyright © 2017年 WY. All rights reserved.
//

#import "SCApiTool+base.h"

@implementation SCApiTool (base)

#pragma mark 店铺分类
+ (void)ScGoodsclassSuccess:(void(^)(NSArray *data))success
                    failure:(void (^)(NSString *errormsg))fail{
    [SCApiTool ZYGet:@"goods/goodsclass"
       netIdentifier:@"goods/goodsclass"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 销售人员列表
+ (void)ScBdlistSuccess:(void(^)(NSArray *data))success
                failure:(void (^)(NSString *errormsg))fail{
    [SCApiTool ZYGet:@"bd/bdlist"
       netIdentifier:@"bd/bdlist"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 发送验证码
+ (void)ScSendPhone:(NSString *)phone
               type:(NSString *)type
            success:(void(^)(NSString *msg))success
            failure:(void (^)(NSString *errormsg))fail{
    
    NSString *secretStr = [NSString stringWithFormat:@"cattlepiephone%@type%@cattlepie",phone,type];
    NSString *secret = [[MyMD5 sha1:secretStr] uppercaseString];
    
    NSDictionary *parmes = @{@"phone":phone,
                             @"type":type,
                             @"secret":secret};
    [SCApiTool ZYPost:@"sms/send"
           parameters:parmes
        netIdentifier:@"sms/send"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}




#pragma mark 照片上传
+ (void)ScUpdatePhoto:(NSArray *)array
                token:(NSString *)token
              Success:(void(^)(NSArray *data))success
              failure:(void (^)(NSString *errormsg))fail{
    
    NSDictionary *parmes = @{@"token":token};
    
    [SCApiTool ZYUpload:@"business/resource/image/upload"
             parameters:parmes
            uploadParam:array
          netIdentifier:[NSString stringWithFormat:@"user/resource/image/upload%d",rand()]
               progress:nil
                success:^(ZYJsonData *data) {
                    success(data.data);
                } failure:^(NSString *msg) {
                    fail(msg);
                }];
}

#pragma mark 刷新token
+ (void)ScRefreshSuccess:(void(^)(NSArray *data))success
                 failure:(void (^)(NSString *errormsg))fail{
    [SCApiTool ZYGet:@"business/auth/refresh"
       netIdentifier:@"business/auth/refresh"
            progress:nil
             success:^(ZYJsonData *data) {

                 [SCUserTool logIn:[SCUserTool loadUserData:data.data]];
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 绑定手机号
+ (void)ScBindmobildPhone:(NSString *)phone
                     code:(NSString *)code
                   unioid:(NSString *)unioid
                  success:(void(^)(NSString *msg))success
                  failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"phone":phone,
                             @"code":code,
                             @"unioid":unioid};
    
    [SCApiTool ZYGet:@"business/auth/bindmobild"
          parameters:parmes
       netIdentifier:@"business/auth/bindmobild"
            progress:nil
             success:^(ZYJsonData *data) {
                 [SCUserTool logIn:[SCUserTool loadUserData:data.data]];
                 success(data.msg);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 检查手机号是否存在
+ (void)ScCheckexist:(NSString *)member_mobile
             success:(void(^)(NSString *msg))success
             failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"member_mobile":member_mobile,
                             @"member_type":@"business"};
    [SCApiTool ZYGet:@"member/checkexist"
          parameters:parmes
       netIdentifier:@"member/checkexist"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.msg);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}
#pragma mark 获取APP最新版本
+ (void)SCversionSuccess:(void(^)(NSDictionary *dic))success
                 failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"platform":@"ios",
                             @"type":@"business"
                             };
    [SCApiTool ZYGet:@"system/version"
          parameters:parmes
       netIdentifier:@"system/version"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}




@end
